<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            position: relative;
            margin: 50px auto;
            width: 490px;
            height: 170px;
            padding: 10px;
            border: 1px solid #000000;
        }
        .box>.inner{
            position: relative;
            height: 100%;
            overflow: hidden;
        }
        .box>.inner>ul{
            position: absolute;
            top: 0;
            left: 0;
            width: 500%;
            height: 100%;
            list-style: none;
        }
        .box>.inner>ul>li{
            float: left;
            
        }
        .box>.inner>ul>li>img{
            /* 取消垂直的间隙 */
            vertical-align: top;
        }
        .box>ol{
            position: absolute;
            bottom: 15px;
            left: 50%;
            list-style: none;
            transform: translateX(-50%);
            /* background-color: gold; */
        }
        .box>ol>li{
            float: left;
            width: 20px;
            height: 20px;
            margin-left: 5px;
            background-color: #fff;
            text-align: center;
            line-height: 20px;
            cursor: pointer;
        }
        .box>ol>li:nth-child(1){
            margin-left: 0;
        }
        .box>ol>li.selected{
            background-color: orange;
        }
    </style>
    <script>
        window.onload = function(){
            var olLis = document.querySelectorAll('ol>li')
            var uls = document.querySelector('ul')
            var target = 0 //目标值
            var leader = 0 //步长
            olLis.forEach((item,index)=>{
                item.onmouseover = function(){
                    olLis.forEach((item,index)=>{
                        item.className = ''
                    })
                    this.className = 'selected'
                    target = -index * 490
                }
            })
            setInterval(()=>{
                leader = leader + (target - leader) / 10
                uls.style.left= leader +'px'
            },30)
        }
    </script>
</head>
<body>
    <div class="box">
        <div class="inner">
            <ul>
                <li><img src="./01.jpg" alt=""></li>
                <li><img src="./02.jpg" alt=""></li>
                <li><img src="./03.jpg" alt=""></li>
                <li><img src="./04.jpg" alt=""></li>
                <li><img src="./05.jpg" alt=""></li>
            </ul>
        </div>

        <ol>
            <li class="selected">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ol>
    </div>
</body>
</html>